import requests
from bs4 import BeautifulSoup
from lxml import etree

class ZhiCity:
    def __init__(self):
        self.header = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36',
            'Content-type': 'text/html',
            'charset': 'utf-8'}


    def get_project(self):
        for i in range(230826,230827):
            url = "http://www.taskcity.com/projects/230827"
            response = requests.get(url,params={},headers = self.header)

            #print(html.content.decode("utf-8"))

            #soup = BeautifulSoup(html.text, "html.parser" )
            #name = soup.select("#project_title_name")


            html = etree.HTML(response.text)
            name = html.xpath('/html/body/div[1]/div/div[2]/div[1]/h1/text()')
            prize = html.xpath('/html/body/div[1]/div/div[7]/div[1]/div[1]/div[2]/b/text()')
            skill = html.xpath('/html/body/div[1]/div/div[7]/div[1]/div[1]/div[4]/text()')
            time = html.xpath('/html/body/div[1]/div/div[7]/div[1]/div[1]/div[3]/b/text()')
            date = html.xpath('/html/body/div[1]/div/div[7]/div[1]/div[1]/div[5]/text()')


            '''
            prize = soup.select("body > div.container > div > div:nth-child(8) > div.col-sm-7 > div.pull-left.space-right-30 > div:nth-child(2) > b")
            skill = soup.select("#body > div.container > div > div:nth-child(8) > div.col-sm-7 > div.pull-left.space-right-30 > div:nth-child(4) > a")
            time = soup.select("#body > div.container > div > div:nth-child(8) > div.col-sm-7 > div.pull-left.space-right-30 > div:nth-child(3) > b")
            date = soup.select("#body > div.container > div > div:nth-child(8) > div.col-sm-7 > div.pull-left.space-right-30 > div:nth-child(5)")
            '''
            print("*************************************************************************")

            print(name)
            print(prize)
            print(skill)
            print(time)
            print(date)

            print("-------------------------------------------------------------------------")


if __name__ in "__main__":
    cls = ZhiCity()
    cls.get_project()
